package com.kgc.novel.util;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CutOut {


    //[4a8ab846fc334c859ea443cf8d38c499.png, 0db1d26480ac49c49efdbb2cb18310dc.png]

    /**
     * 删除开头字符串
     * 获取 4a8ab846fc334c859ea443cf8d38c499.png, 0db1d26480ac49c49efdbb2cb18310dc.png]
     */
    public static String trimstart(String inStr, String prefix) {
        if (inStr.startsWith(prefix)) {
            return (inStr.substring(prefix.length()));
        }
        return inStr;
    }
    /**
     * 删除末尾字符串
     * 获取 4a8ab846fc334c859ea443cf8d38c499.png, 0db1d26480ac49c49efdbb2cb18310dc.png
     */
    public static String trimend(String inStr, String suffix) {
        if (inStr.endsWith(suffix)) {
            return (inStr.substring(0,inStr.length()-suffix.length()));
        }
        return inStr;
    }

    public static List<String> tagId(String images){
        List<String> tagId=new ArrayList<>();
        if (images!=null){
            String trimstart = trimstart(images, "[");
            String trimend = trimend(trimstart, "]");
            String[] split = trimend.split(",");
            tagId.addAll(Arrays.asList(split));
        }
        return tagId;
    }


}
